package com.rs.report;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import com.rs.cache.QueueName;
import com.rs.entity.dto.DetectionDTO;
import com.rs.push.DevicePushMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * 探测上报
 *
 * @author zhouwz
 * @date 2020/9/30 15:09
 */
@Component
public class DetectionReport {

    private final RabbitTemplate rabbitTemplate;

    public DetectionReport(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void generatorDetectionInfo(String vehicleCode) {
        String shelfNo = "M00001";
        int shelfAngle = RandomUtil.randomInt(-180, 180);
        rabbitTemplate.convertAndSend(QueueName.DETECTION_QUEUE, BeanUtil.beanToMap(new DetectionDTO(vehicleCode, shelfNo, shelfAngle, DevicePushMessage.nodeReportHistory.get(vehicleCode))));
    }
}
